<script type="text/javascript">
    // $(this).ready(function(){
    // $('.tag_show').hover(function() {
    // $(this).children("span").show();
    // }, function() {
    // $(this).children("span").hide();
    // });
    // })
    function reload_tags(){
    	<% #@tags = obj.reload.tag_list %>
    	<% @tags = obj.attributes["tags"]
    	   if @tags != nil && @tags.length>2
    	   		@tags = @tags[1,@tags.length-2].split(">,<")
    	   end %>
    }
</script>

<% if non_list_all and !@tags.nil? and (@tags.size > 0) %>
    <!-- 这里是显示的非主页的tag 所以当tag数量较多时 不必全部显示 用“更多”代替  -->
    <% if @tags.size > Setting.show_tags_length.to_i then %>
        <% i = 0 %>

        <% until i>Setting.show_tags_length.to_i do %>
            <div id="tag">
              <%= link_to @tags[i], {:controller => "tags", :action => "index", :q => @tags[i].to_s, :object_flag => object_flag, :obj_id => obj.id}, :onclick => "return user_trace_click_tag('#{obj.id}', '#{i+1}', '#{request.session_options[:id]}', '#{@tags[i].to_s}');" %>
            </div>
            <% i += 1 %>
        <% end %>

        <%= link_to l(:label_more_tags), {:action => "show", :id => obj.id}, :onclick => "return user_trace_click_more_tags('#{obj.id}', '#{request.session_options[:id]}');" %>

    <% else %>

        <% for i in (0..@tags.length-1) %>
        	<% tag = @tags[i] %>
            <div id="tag">
              <%= link_to tag, {:controller => "tags", :action => "index", :q => tag.to_s, :object_flag => object_flag, :obj_id => obj.id}, :onclick => "return user_trace_click_tag('#{obj.id}', '#{i+1}','#{request.session_options[:id]}', '#{@tags[i].to_s}');" %>
            </div>
        <% end %>

    <% end %>

<% else %>
   		 <!-- 用来显示三大对象的主页中的tag  故是全部显示  -->
    	<% if !@tags.nil? and @tags.size > 9 then %>
		<!-- <#%= link_to (image_tag "/images/sidebar/tag_disagree.png"), :controller => "users", :action => "tag_disagree" %> -->
		<!-- 倒标签 -->
		<!-- <a href="/users/tag_disagree?tag_name=<#%= tag%>&obj_id=<#%= obj.id%>" class="glyphicon glyphicon-thumbs-down" aria-hidden="true"></a>  -->
        <% i = 0 %>
        <% until i>Setting.show_tags_length.to_i do %>
            <div id="tag">
            	<span class="tag_show"> 
              	<%= link_to @tags[i], {:controller => "tags", :action => "index", :q => @tags[i].to_s, :object_flag => object_flag, :obj_id => obj.id}, :onclick => "return user_trace_click_tag('#{obj.id}', '#{i+1}', '#{request.session_options[:id]}', '#{@tags[i].to_s}');" %>
            	</span>
            </div>
            <% i += 1 %>
        <% end %>
        <a href="javascript:void(0)" onclick="reload_tags()"><%= l(:label_more_tags)%></a>
    	<% elsif !@tags.nil? and  @tags.size > 0 %>
        <% for i in (0..@tags.length-1) %>
        	<% tag = @tags[i] %>
           	<div id="tag">
             <%= link_to tag, {:controller => "tags", :action => "index", :q => tag.to_s, :object_flag => object_flag, :obj_id => obj.id}, :onclick => "return user_trace_click_tag('#{obj.id}', '#{i+1}','#{request.session_options[:id]}', '#{@tags[i].to_s}');" %>
            </div>
         <% end %>
        <% else %>
        	<span style="color:#8c8a8a"> &nbsp;&nbsp;&nbsp;<%= l(:label_tags_no) %></span>
   		<% end %>			
 <% end %>
 <!-- ajax user trace zhangxunhui begin -->
<script type="text/javascript">
	function user_trace_click_more_tags(osp_id,session_id){
    	$.ajax({
			contentType: "application/json; charset=utf-8",
			timeout: 5000,
			url: '/user_traces/click_more_tags?osp_id=' + osp_id + "&session_id=" + session_id,
			dataType: "json"
		});
	}
</script>
<!-- ajax user trace zhangxunhui end -->

 <!-- ajax user trace zhangxunhui begin -->
<script type="text/javascript">
	function user_trace_click_tag(osp_id,rank,session_id,tag_name){
		//项目详情页面点击tag session无法在后台获取 可能是因为不是request请求
		tag_name = encodeURIComponent(tag_name);
    	$.ajax({
			type: "post",
			contentType: "application/json; charset=utf-8",
			url: '/user_traces/click_tag?osp_id=' + osp_id + "&rank=" + rank + "&session_id=" + session_id + "&tag_name=" + tag_name,
			dataType: "json"
		});
	}
</script>
<!-- ajax user trace zhangxunhui end -->
